class Solution(object):
    def mySqrt(self, x):
        """
        :type x: int
        :rtype: int
        """
        #蓝红划分法，上界最大数下标+1
        l = -1 
        h = x + 1
        while l != h - 1:
            mid = (h + l) / 2
            m_square = int(mid * mid)
            if m_square <= x:
                l = mid
            else:
                h = mid
        return l
